﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using iLangl.Customer.DNN.Entities;


namespace iLangl.Customer.DNN.Controls
{
	public class ContentTreeNode : ITemplate
	{
		public ContentTreeNode()
		{
		
		}
		#region ITemplate Members

		public void InstantiateIn(Control container)
		{
			Label label1 = new Label();
			label1.ID = "ItemLabel";
			label1.Text = "Text";
			label1.Font.Size = 12;
			label1.Font.Bold = true;
			label1.DataBinding += new EventHandler(label1_DataBinding);
			container.Controls.Add(label1);

			if (eСontent == null)
				return;

			foreach (dtoContent.LanguagePairsRow lpr in eСontent.LanguagePairs)
			{
				if (lpr.SourceLanguage == SourceLanguage)
				{
					CheckBox cbLanguage = new CheckBox();
					cbLanguage.Attributes["class"] = "rtChk";
					
					cbLanguage.Text = lpr.TargetLanguage;
					cbLanguage.Font.Size = 10;
					cbLanguage.Font.Bold = true;
					cbLanguage.CheckedChanged += new EventHandler(cbLanguage_CheckedChanged);
					
					container.Controls.Add(cbLanguage);
				}
			}
			
		}

		void cbLanguage_CheckedChanged(object sender, EventArgs e)
		{
			throw new NotImplementedException();
		}

		private void label1_DataBinding(object sender, EventArgs e)
		{
			Label target = (Label)sender;
			RadTreeNode node = (RadTreeNode)target.BindingContainer;
			string nodeText = (string)DataBinder.Eval(node, "Text");
			target.Text = nodeText;
		}

		private String sourceLanguage;
		public String SourceLanguage
		{
			get
			{
				return sourceLanguage;
			}
			set
			{
				sourceLanguage = value;
			}
		}

		private dtoContent content= null;
		public dtoContent eСontent
		{
			get
			{
				return content;
			}
			set
			{
				content = value;
			}
		}

		#endregion
	}
}